# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-github-google-safehtml
pkgver=0.0.2
pkgrel=1
pkgdesc="Safe HTML for Go"
arch=('any')
url="https://github.com/google/safehtml"
license=('BSD')
depends=('go' 'golang-golang-x-text')
source=("$pkgname-$pkgver.tar.gz::https://github.com/google/safehtml/archive/v$pkgver.tar.gz")
sha512sums=('02d1984a19d799b74e01bb99b65c4970696093474e52fca3c8c8fcd42daf5450a1a6bd80f4c94463d9286e13246adace6bb16c2202dbc2e14dbe55db55c62a49')

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/github.com/google
  cp -a "$srcdir"/safehtml-$pkgver "$srcdir"/build/src/github.com/google/safehtml
  cd "$srcdir"/build/src/github.com/google/safehtml
  go test -v $(go list ./...)
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/github.com/google
  cp -a "$srcdir"/safehtml-$pkgver "$pkgdir"/usr/share/gocode/src/github.com/google/safehtml

  install -Dm644 safehtml-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
